﻿
using System.ServiceModel;
using System.ServiceModel.Activation;
using System;

namespace OpenLightGroup.Common.ApplicationServices
{
    [ServiceContract(Namespace = "http://openlightgroup.net/ApplicationServices/EventLoggerService/2011/05/")]
    [SilverlightFaultBehavior]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class EventLoggerService
    {
        [OperationContract]
        public bool IsAlive()
        {
            return true ;
        }

        [OperationContract]
        public void Debug(EventLogRequest request)
        {
            EventLogger.LogClientDebugEvent(request);
        }

        [OperationContract]
        public string Log (EventLogRequest request)
        {
            
            switch (request.EventType)
            {
                case ClientEventTypes.Debug:

                    Debug(request);
                    
                    break;

                case ClientEventTypes.Information:                    
                    
                    EventLogger.LogClientEvent<ClientInformationEvent> ( request ) ;

                    break;

                case ClientEventTypes.Warning:

                    EventLogger.LogClientEvent<ClientWarningEvent>(request);

                    break;

                case ClientEventTypes.Error:

                    LogError ( request ) ;

                    break;

                default:
                    break;
            }

            return "Complete" ;
        }

       
        [OperationContract]
        public void LogError(EventLogRequest request)
        {
           EventLogger.LogClientErrorEvent(request);

        }

        //[OperationContract]
        //public void LogWarning(string message, object source, int detailCode)
        //{
        //    //EventLogger.LogWarning(message);
        //    EventLogger.Log<WarningEvent>(message, source, detailCode);
        //}

        //[OperationContract]
        //public void LogInformation(string message, object source, int detailCode)
        //{
        //    EventLogger.Log<InformationEvent> ( message, source, detailCode ) ;
        //}
    }
}
